<template>
	<el-dialog :visible.sync="visible" width="50%" title="人员分配" 
		:close-on-click-modal="false" :close-on-press-escape="false"
		:modal-append-to-body="false" :append-to-body="true">
		<el-tag v-for="(xgh, i) in xghs" :key="xgh" style="margin-right:10px; margin-bottom:5px;">{{xgh}}</el-tag>
	</el-dialog>
</template>

<script>
import request from '@/utils/request';

export default {
	data() {
		return {
			visible: false,
			domitoryId: null,
			xghs: [],
		}
	},
	methods: {
		open(domitory) {
			this.visible = true;
			this.domitoryId = domitory.id;
		}
	},
	watch: {
		'domitoryId': function(newVal, oldVal) {
			let self = this;
			request({
				url: 'api/userDomitory/search',
				params: {
					domitoryId: self.domitoryId,
					page: 1,
					size: 1000
				}
			}).then(data => {
				let xghs = [];
				data.list.forEach(e => {
					xghs.push(e.xgh);
				});
				self.xghs = xghs;
			}).catch(error => {
				
			});
		}
	}
}
</script>